﻿using mvcForum.Core.Interfaces.Data;
using System;
using System.Linq.Expressions;


namespace mvcForum.Core.Specifications {

	public static class ForumAccessSpecifications {

		public class SpecificForumAndGroup : ISpecification<ForumAccess> {
			private readonly Forum forum;
			private readonly Group group;

			public SpecificForumAndGroup(Forum forum, Group group) {
				this.forum = forum;
				this.group = group;
			}

			public Expression<Func<ForumAccess, Boolean>> IsSatisfied {
				get {
					return x => x.GroupId == group.Id && x.ForumId == forum.Id;
				}
			}
		}

		public class SpecificForum : ISpecification<ForumAccess> {
			private readonly Forum forum;

			public SpecificForum(Forum forum) {
				this.forum = forum;
			}

			public Expression<Func<ForumAccess, Boolean>> IsSatisfied {
				get {
					return x => x.Forum.Id == forum.Id;
				}
			}
		}
	}
}